package DesignPatern.A10_责任链模式.QSB.A01_未用责任链模式;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Author: Du
 * @Date: 2021/7/28 9:24
 */
public class A01_Main
{
    public static void main(String[] args)
    {
        Random random = new Random();
        ArrayList<IWomen> arrayList = new ArrayList<>();
        for (int i = 0; i < 5; i++)
        {
            arrayList.add(new Women(random.nextInt(4), "去逛街"));
        }
        
        IHandler father = new Father();
        IHandler husband = new Husband();
        IHandler son = new Son();
        
        for (IWomen iWomen : arrayList)
        {
            if (iWomen.getType() == 1)
            {
                System.out.println("向父亲请示");
                father.HandleMessage(iWomen);
            } else if (iWomen.getType() == 2)
            {
                System.out.println("向丈夫请示");
                husband.HandleMessage(iWomen);
            } else if (iWomen.getType() == 3)
            {
                System.out.println("向儿子请示");
                son.HandleMessage(iWomen);
            } else
            {
            
            }
        }
    }
}
